<template>
  <a-modal
    :title="`测试流水表` + title"
    :width="640"
    destroyOnClose
    centered
    :visible="visible"
    :confirmLoading="loading"
    @ok="handleSubmit('transId')"
    @cancel="visible=!visible"
  >
    <a-spin :spinning="loading">
      <a-form :form="form" v-bind="formLayout">
        <a-form-item label="主键ID" v-show="model.id" >
          <a-input v-decorator="['id', { initialValue: model.id }]" disabled />
        </a-form-item>
        <a-form-item label="交易流水号">
          <a-input v-decorator="['transId', {initialValue: model.transId,rules: [{ required: true, message: '交易流水号不能为空！' }]}]" disabled />
        </a-form-item>
        <a-form-item label="交易类型">
          <a-select
            show-search
            placeholder="请选择"
            v-decorator="['transType', {initialValue: model.transType,rules:[{ required: true, message: '交易类型不能为空！' }]}]">
            <a-select-option v-for="(value, key) in this.trans_type" :key="parseInt(key)">
              ({{ key }}){{ value.dictValue }}
            </a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="订单日期">
          <a-input v-decorator="['orderDate', {initialValue: model.orderDate,rules: [{ required: true, message: '订单日期不能为空！' }]}]"/>
        </a-form-item>
        <a-form-item label="订单金额">
          <a-input v-decorator="['orderAmount', {initialValue: this.amountFix(model.orderAmount, 100, 2),rules: [{ required: true, message: '订单金额不能为空！' }]}]"/>
        </a-form-item>
        <a-form-item label="手续费">
          <a-input v-decorator="['orderFee', {initialValue: this.amountFix(model.orderFee, 100, 2),rules: [{ required: true, message: '手续费不能为空！' }]}]"/>
        </a-form-item>
        <a-form-item label="费率">
          <a-input v-decorator="['orderFeeRate', {initialValue: model.orderFeeRate,rules: [{ required: true, message: '费率不能为空！' }]}]"/>
        </a-form-item>
        <a-form-item label="银行帐号">
          <a-input v-decorator="['bankAccountNo', {initialValue: model.bankAccountNo,rules: [{ required: true, message: '银行帐号不能为空！' }]}]"/>
        </a-form-item>
        <a-form-item label="银行户名">
          <a-input v-decorator="['bankAccountName', {initialValue: model.bankAccountName,rules: [{ required: true, message: '银行户名不能为空！' }]}]"/>
        </a-form-item>
        <a-form-item label="客户手机">
          <a-input v-decorator="['mobile', {initialValue: model.mobile,rules: [{ required: true, message: '客户手机不能为空！' }]}]"/>
        </a-form-item>
        <a-form-item label="证件号码">
          <a-input v-decorator="['certificateNo', {initialValue: model.certificateNo,rules: [{ required: true, message: '证件号码不能为空！' }]}]"/>
        </a-form-item>
        <a-form-item label="交易状态">
          <a-select
            show-search
            placeholder="请选择"
            v-decorator="['state', {initialValue: model.state,rules:[{ required: true, message: '交易状态不能为空！' }]}]">
            <a-select-option v-for="(value, key) in this.demo_state" :key="parseInt(key)">
              ({{ key }}){{ value.dictValue }}
            </a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="审核状态">
          <a-select
            show-search
            placeholder="请选择"
            v-decorator="['auditState', {initialValue: model.auditState,rules:[{ required: true, message: '审核状态不能为空！' }]}]">
            <a-select-option v-for="(value, key) in this.audit_state" :key="parseInt(key)">
              ({{ key }}){{ value.dictValue }}
            </a-select-option>
          </a-select>
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>
<script>
  import detailMixins from '@/utils/mixins/detailMixins'
  import { getInfo, addInfo, editInfo } from '@/api/trade/demo'
  export default {
    mixins: [detailMixins],
    data () {
      return {
        trans_type: {},
        demo_state: {},
        audit_state: {},
        genTemp: null
      }
    },
    created () {
      this.getDictValue('trans_type').then(res => {
        this.trans_type = res.data
      })
      this.getDictValue('demo_state').then(res => {
        this.demo_state = res.data
      })
      this.getDictValue('audit_state').then(res => {
        this.audit_state = res.data
      })
    },
    methods: {
      filterForm (values) {
        values.orderAmount = this.amountFix(parseFloat(values.orderAmount), 1 / 100, 0)
        values.orderFee = this.amountFix(parseFloat(values.orderFee), 1 / 100, 0)
        return values
      },
      info (record) {
        return getInfo(record, 'transId')
      },
      add (values) {
        return addInfo(values)
      },
      edit (values) {
        return editInfo(values)
      }
    }
  }
</script>
<style scoped>
</style>
